# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from itemadapter import ItemAdapter

import json
class Douban250Pipeline:
    def process_item(self, item, spider):
        print(item)
        print(type(item))  #<class 'douban250.items.Douban250Item'> 是一个对象 可以进行键取值
        items=dict(item)
        print("这是测试代码")
        with open("豆瓣1.txt","w",encoding="utf-8")as file1:
            str_data=json.dumps(items,ensure_ascii=False)
            file1.write(str_data)
        return item

